package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//h5套餐管理模块
@RestController
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    //根据 分类id+ 状态查询套餐列表
    // 请求方式 ：Get
    // 请求地址:http://localhost:8081/setmeal/list?categoryId=1413342269393674242&status=1
    //请求参数：categoryId=1413342269393674242&status=1

    @GetMapping("/setmeal/list")
    public ResultInfo findList(Long categoryId, Integer status) {
        //调用service
        List<Setmeal> setmealList = setmealService.findList(categoryId, status);
        //返回结果
        return ResultInfo.success(setmealList);
    }

    //查看套餐详情
    @GetMapping("/setmeal/dish/{id}")
    public ResultInfo findDishDetail(@PathVariable("id") Long id) {//接受参数
        //调用service
        List<Dish> dishList=  setmealService.findDishDateil(id);
        //返回结果
        return ResultInfo.success(dishList);
    }
}
